#!usr/bin/node

const http = require('http'),
      {join} = require('path'),
      fs = require("fs");

http.createServer((req,res) => {
  let fileName = req.url.substr(1,req.url.length-1);
  fileName = join(__dirname,fileName);

  let content;
  try{
    content = fs.readFileSync(fileName,'utf-8');
  }catch(e) {
    content = e.message;
  }

  //console.log(fileName);
  res.end(content);
}).listen(8080);


